﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLogic;

namespace Interface
{
    public partial class Login : System.Web.UI.Page
    {
        DataConnection dc = new DataConnection();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ibtnLogin_Click(object sender, ImageClickEventArgs e)
        {
            if (dc.checkUser(txtUsername.Text, txtPass.Text) == true)
            {

                string userName = txtUsername.Text;
                if (dc.getLoaiUser(userName) == "Admin")
                {
                    Session["AdminSession"] = userName;
                }
                else if (dc.getLoaiUser(userName) == "Chủ nhà")
                {
                    Session["OwnerSession"] = userName;
                }
                else
                {
                    Session["CustomerSession"] = userName;
                }
                Response.Redirect("~/Home.aspx");
                
            }
            else
            {
                lblMs.Text = "Đăng nhập thất bại, vui lòng thử lại";
            }
        }

       
    }
}